﻿using System;
using System.Collections.Generic;

namespace IOA.MES.DataAccess.VModel
{
    /// <summary>
    /// 返修工单
    /// </summary>
    public class VReworkOrder : BaseVModel
    {
        private string _reworkNo = string.Empty;
        private string _orderNo = string.Empty;
        private string _customerCode = string.Empty;
        private string _customerName = string.Empty;
        private string _workshopCode = string.Empty;
        private string _workshopName = string.Empty;
        private string _remark = string.Empty;
        private string _reviewDesc = string.Empty;
        private string _cnReviewBy = string.Empty;

        #region Public Property

        ///<Summary>
        /// 返修类型（按订单、按工单）
        ///</Summary>
        public Enum.ReworkType ReworkType { get; set; }

        ///<Summary>
        /// 返修单号
        ///</Summary>
        public string ReworkNo
        {
            get { return string.IsNullOrWhiteSpace(_reworkNo) ? string.Empty : _reworkNo; }
            set { _reworkNo = value; }
        }

        ///<Summary>
        /// 订单号
        ///</Summary>
        public string OrderNo
        {
            get { return string.IsNullOrWhiteSpace(_orderNo) ? string.Empty : _orderNo; }
            set { _orderNo = value; }
        }

        ///<Summary>
        /// 客户代码
        ///</Summary>
        public string CustomerCode
        {
            get { return string.IsNullOrWhiteSpace(_customerCode) ? string.Empty : _customerCode; }
            set { _customerCode = value; }
        }

        ///<Summary>
        /// 客户名称
        ///</Summary>
        public string CustomerName
        {
            get { return string.IsNullOrWhiteSpace(_customerName) ? string.Empty : _customerName; }
            set { _customerName = value; }
        }

        ///<Summary>
        /// 车间代码
        ///</Summary>
        public string WorkshopCode
        {
            get { return string.IsNullOrWhiteSpace(_workshopCode) ? string.Empty : _workshopCode; }
            set { _workshopCode = value; }
        }

        ///<Summary>
        /// 车间名称
        ///</Summary>
        public string WorkshopName
        {
            get { return string.IsNullOrWhiteSpace(_workshopName) ? string.Empty : _workshopName; }
            set { _workshopName = value; }
        }

        /// <summary>
        /// 生产状态
        /// </summary>
        public Enum.ProduceStatus ProduceStatus { get; set; }

        ///<Summary>
        /// 返工说明
        ///</Summary>
        public string Remark
        {
            get { return string.IsNullOrWhiteSpace(_remark) ? string.Empty : _remark; }
            set { _remark = value; }
        }

        ///<Summary>
        /// 审核状态
        ///</Summary>
        public Enum.ReviewStatus ReviewStatus { get; set; }

        ///<Summary>
        /// 审核人
        ///</Summary>
        public int ReviewBy { get; set; }

        ///<Summary>
        /// 审核时间
        ///</Summary>
        public DateTime? ReviewTime { get; set; }

        ///<Summary>
        /// 审核说明
        ///</Summary>
        public string ReviewDesc
        {
            get { return string.IsNullOrWhiteSpace(_reviewDesc) ? string.Empty : _reviewDesc; }
            set { _reviewDesc = value; }
        }
        #endregion

        ///<Summary>
        /// 审核人
        ///</Summary>
        public string CNReviewBy
        {
            get { return string.IsNullOrWhiteSpace(_cnReviewBy) ? string.Empty : _cnReviewBy; }
            set { _cnReviewBy = value; }
        }

        public string ReviewTimeStr { get { return ReviewTime?.ToString("yyyy-MM-dd HH:mm:ss") ?? string.Empty; } }

        public string CNReworkType { get { return !System.Enum.IsDefined(typeof(Enum.ReworkType), ReworkType) ? string.Empty : EnumConvert.ToDesc(ReworkType); } }
        public string CNProduceStatus { get { return !System.Enum.IsDefined(typeof(Enum.ProduceStatus), ProduceStatus) ? string.Empty : EnumConvert.ToDesc(ProduceStatus); } }
        public string CNReviewStatus { get { return !System.Enum.IsDefined(typeof(Enum.ReviewStatus), ReviewStatus) ? string.Empty : EnumConvert.ToDesc(ReviewStatus); } }


        /// <summary>
        /// 过站站点
        /// </summary>
        public List<VReworkSite> Sites { get; set; } = new List<VReworkSite>();

        /// <summary>
        /// 返工对象列表
        /// </summary>
        public List<VReworkItem> Items { get; set; } = new List<VReworkItem>();

        /// <summary>
        /// 返工BOM列表
        /// </summary>
        public List<VReworkBom> Boms { get; set; } = new List<VReworkBom>();
    }
}
